<template>
  <div>
    <el-row>
      <el-col :span="24">
        <!-- <h5>自定义颜色</h5> -->
        <el-menu
          router
          default-active="2"
          class="el-menu-vertical-demo"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
        >
          <el-submenu v-for="(item, index) in menuList" :key="index" :index="index+''">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>{{item.title}}</span>
            </template>
            <el-menu-item-group v-for="(item1, index1) in item.children" :key="index1+'sub'">
              <el-menu-item :index="item1.url">{{item1.title}}</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>

<script>
// 辅助函数 侧边栏的数据来自vuex
import {getMenuListTree} from '../http'
export default {
  created() {
    // 发请求获取-muenList
    this.getMenuList()
  },
  data() {
    return {
      menuList: [],
    };
  },
  methods: {
    async getMenuList() {
      let res = await getMenuListTree();
      this.menuList = res.list;
    }
  }
};
</script>

<style>
</style>